<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.js"></script>
</head>

<body>
    <div class="app">
        <!-- 遍历数组 -->
        <ul>
            <li v-for="p in person" :key="p.id">{{p.name}}-{{p.age}}</li>
        </ul>
        <ul>
            <li v-for="(p,index) in person" :key="index">{{p.name}}-{{p.age}}</li>
        </ul>
        <!-- 遍历对象 -->
        <ul>
            <li v-for="(value,key) of car" :key="key">{{key}}-{{value}}</li>
        </ul>
        <!-- 遍历字符串 -->
        <ul>
            <li v-for="(value,k) of str" :key="k">{{k}}-{{value}}</li>
        </ul>
        <!-- 遍历指定次数 -->
        <ul>
            <li v-for="(value,k) of str" v-if="k<3" :key="k">{{k}}-{{value}}</li>
        </ul>
    </div>
    <script>
        const vm = new Vue({
            data: {
                person: [{
                    id: '001',
                    name: '张三',
                    age: 18
                }, {
                    id: '002',
                    name: '李四',
                    age: 19
                }, {
                    id: '003',
                    name: '牛五',
                    age: 20
                }],
                car: {
                    name: '布加迪',
                    price: '50包邮',
                    color: 'black'
                },
                str: 'hello'
            }
        })
        vm.$mount('.app')
    </script>

</body>

</html>